﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ICTBilling;

/// <summary>
/// Summary description for tbCenter
/// </summary>
public partial class tbCenter : IValidate
{
    public List<ExceptionHandler> Validate(ChangeAction changeAction)
    {
        List<ExceptionHandler> ExecutionCollection = new List<ExceptionHandler>();
        try
        {
            if (changeAction == ChangeAction.Insert ||
                changeAction == ChangeAction.Update)
            {
                if (changeAction == ChangeAction.Update && this.PkCenterID == null)
                    ExecutionCollection.Add(new ExceptionHandler("PkCenterID", "شناسه مرکز", ICTBilling.ExceptionType.NullArgumant));

                if (this.FkLocationID == null)
                    ExecutionCollection.Add(new ExceptionHandler("FkLocationID", "منطقه", ICTBilling.ExceptionType.NullArgumant));

                if (this.CenterName == null)
                    ExecutionCollection.Add(new ExceptionHandler("CenterName", "نام مرکز", ICTBilling.ExceptionType.NullArgumant));

                if (this.CenterPass == null)
                    ExecutionCollection.Add(new ExceptionHandler("CenterPass", "رمز شناسایی", ICTBilling.ExceptionType.NullArgumant));

                if (this.LA == null)
                    ExecutionCollection.Add(new ExceptionHandler("LA", "طول جغرافیایی", ICTBilling.ExceptionType.NullArgumant));
                else
                {
                    try
                    {
                        float.Parse(this.LA.ToString());
                    }
                    catch (FormatException)
                    {
                        ExecutionCollection.Add(new ExceptionHandler("LA", "طول جغرافیایی", ICTBilling.ExceptionType.LongFormat));
                    }
                }

                if (this.LE == null)
                    ExecutionCollection.Add(new ExceptionHandler("LE", "عرض جغرافیایی", ICTBilling.ExceptionType.NullArgumant));
                else
                {
                    try
                    {
                        float.Parse(this.LE.ToString());
                    }
                    catch (FormatException)
                    {
                        ExecutionCollection.Add(new ExceptionHandler("LE", "عرض جغرافیایی", ICTBilling.ExceptionType.LongFormat));
                    }
                }

                if (this.Tel == null)
                    ExecutionCollection.Add(new ExceptionHandler("Tel", "تلفن", ICTBilling.ExceptionType.NullArgumant));

                if (this.Fax == null)
                    ExecutionCollection.Add(new ExceptionHandler("Fax", "فکس", ICTBilling.ExceptionType.NullArgumant));

                if (this.Address == null)
                    ExecutionCollection.Add(new ExceptionHandler("Address", "آدرس", ICTBilling.ExceptionType.NullArgumant));

                if (this.Area == null)
                    ExecutionCollection.Add(new ExceptionHandler("Area", "مساحت هر مرکز", ICTBilling.ExceptionType.NullArgumant));
                else
                {
                    try
                    {
                        double.Parse(this.Area.ToString());
                    }
                    catch (FormatException)
                    {
                        ExecutionCollection.Add(new ExceptionHandler("Area", "مساحت هر مرکز", ICTBilling.ExceptionType.LongFormat));
                    }
                }

                if (this.PersonNo == null)
                    ExecutionCollection.Add(new ExceptionHandler("PersonNo", "تعداد پرسنل هر مرکز", ICTBilling.ExceptionType.NullArgumant));
                else
                {
                    try
                    {
                        int.Parse(this.PersonNo.ToString());
                    }
                    catch (FormatException)
                    {
                        ExecutionCollection.Add(new ExceptionHandler("PersonNo", "تعداد پرسنل هر مرکز", ICTBilling.ExceptionType.IntFormat));
                    }
                }

            }
        }
        catch (Exception _Exception)
        {
            ExecutionCollection.Add(new ExceptionHandler(_Exception));
        }
        return ExecutionCollection;
    }
}